﻿namespace FSpec.Runner

open System

[<AutoOpen>]
module ControllerHelper =
    let shuffle (_array:array<'a>) =
        let swap i j =
            let item = _array.[i]
            _array.[i] <- _array.[j]
            _array.[j] <- item

        let rnd = new Random()
        let ln = _array.Length
        
        for i in [0..(ln - 2)] do
            swap i (rnd.Next(i, ln))
        _array
    
    let nullable<'a when 'a : struct 
                 and 'a : (new: unit -> 'a)
                 and 'a :> ValueType > (value:'a) = new System.Nullable<'a>(value)


